package com.jic.product.impl;

import java.lang.Long;
import java.util.List;


import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.product.entity.WarehouseFlowing;
import com.jic.product.mapper.WarehouseFlowingMapper;
import com.jic.product.service.WarehouseFlowingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 实体仓库流水表
 * @author : 
 * @email : 
 * @since : 2020-01-17 05:01:41
 * @version : v1.0.0
 */
@Service
public class WarehouseFlowingServiceImpl implements WarehouseFlowingService {

    @Autowired
    private WarehouseFlowingMapper warehouseFlowingMapper;

    @Override
    public long insert(WarehouseFlowing warehouseFlowing) {
        long flag = warehouseFlowingMapper.insert(warehouseFlowing);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return warehouseFlowingMapper.delete(id);
    }

    @Override
    public long update(WarehouseFlowing warehouseFlowing) {
        return warehouseFlowingMapper.update(warehouseFlowing);
    }

    @Override
    public WarehouseFlowing queryByPrimaryKey(Long id){
        return warehouseFlowingMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<WarehouseFlowing> query(WarehouseFlowing warehouseFlowing){
        return warehouseFlowingMapper.query(warehouseFlowing);
    }

    @Override
    public PageResult<WarehouseFlowing> queryPage(WarehouseFlowing warehouseFlowing, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<WarehouseFlowing> list = warehouseFlowingMapper.queryPage(startIndex, pageQuery.getLimit(), warehouseFlowing);
        long count = warehouseFlowingMapper.queryPageCount(warehouseFlowing);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}